import config from 'config'
import httpFetch from 'share/httpFetch'
import { message } from 'antd'

const authorizeViewServer = (context) => {
  return {

    // 获取单据列表
    async getGeneralViewData(params){
      try {
        context.setState({loading: true});
        const response = await httpFetch.post(`/api/common/document/view/get?size=${params.size}&page=${params.page}`,params);
        response.data.rows = response.data || [];
        return response;
      }catch (err) {
        dealWithErrorMes(err);
      }finally {
        context.setState({loading: false});
      }
    },
  }
}

const dealWithErrorMes = (err) => {
  message.error(`error:${err.response.data.message}`);
}

export default authorizeViewServer;
